#include "PreCompiled.h"
#include "Command.h"
#include "Application.h"
#include "BitmapFactoryInst.h"
#include "Action.h"
#include "MainWindow.h"
#include "VIewWindow.h"
#include "View3DInventor.h"
DEF_3DV_CMD(StdCmdViewBottom);
StdCmdViewBottom::StdCmdViewBottom()
:Command("Std_ViewBottom")
{
	sGroup     = QT_TR_NOOP("View");
	sMenuText  = QT_TR_NOOP("&ViewBottom");
	sToolTipText = QT_TR_NOOP("ViewBottom");
	sWhatsThis  = "Std_ViewBottom";
	sStatusTip = QT_TR_NOOP("ViewBottom");
	sPixmap   = "view-bottom";
}
void StdCmdViewBottom::activated(int iMsg)
{

}

DEF_3DV_CMD(StdCmdViewFront);
StdCmdViewFront::StdCmdViewFront()
:Command("Std_ViewFront")
{
	sGroup     = QT_TR_NOOP("View");
	sMenuText  = QT_TR_NOOP("&ViewFront");
	sToolTipText = QT_TR_NOOP("ViewFront");
	sWhatsThis  = "Std_ViewFront";
	sStatusTip = QT_TR_NOOP("ViewFront");
	sPixmap   = "view-front";
}

void StdCmdViewFront::activated(int iMsg)
{

}

DEF_3DV_CMD(StdCmdViewLeft);
StdCmdViewLeft::StdCmdViewLeft()
:Command("Std_ViewLeft")
{
	sGroup     = QT_TR_NOOP("View");
	sMenuText  = QT_TR_NOOP("&ViewLeft");
	sToolTipText = QT_TR_NOOP("ViewLeft");
	sWhatsThis  = "Std_ViewLeft";
	sStatusTip = QT_TR_NOOP("ViewLeft");
	sPixmap   = "view-left";
}

void StdCmdViewLeft::activated(int iMsg)
{

}


DEF_3DV_CMD(StdCmdViewRight);
StdCmdViewRight::StdCmdViewRight()
:Command("Std_ViewRight")
{
	sGroup     = QT_TR_NOOP("View");
	sMenuText  = QT_TR_NOOP("&ViewRight");
	sToolTipText = QT_TR_NOOP("ViewRight");
	sWhatsThis  = "Std_ViewRight";
	sStatusTip = QT_TR_NOOP("ViewRight");
	sPixmap   = "view-right";
}

void StdCmdViewRight::activated(int iMsg)
{

}

DEF_3DV_CMD(StdCmdViewRear);
StdCmdViewRear::StdCmdViewRear()
:Command("Std_ViewRear")
{
	sGroup     = QT_TR_NOOP("View");
	sMenuText  = QT_TR_NOOP("&ViewRear");
	sToolTipText = QT_TR_NOOP("ViewRear");
	sWhatsThis  = "Std_ViewRear";
	sStatusTip = QT_TR_NOOP("ViewRear");
	sPixmap   = "view-rear";
}
void StdCmdViewRear::activated(int iMsg)
{

}

DEF_3DV_CMD(StdCmdViewTop);
StdCmdViewTop::StdCmdViewTop()
:Command("Std_ViewTop")
{
	sGroup     = QT_TR_NOOP("View");
	sMenuText  = QT_TR_NOOP("&ViewTop");
	sToolTipText = QT_TR_NOOP("ViewTop");
	sWhatsThis  = "Std_ViewTop";
	sStatusTip = QT_TR_NOOP("ViewTop");
	sPixmap   = "view-top";
}
void StdCmdViewTop::activated(int iMsg)
{

}

DEF_STD_CMD_AC(StdViewDockUndockFullscreen);

StdViewDockUndockFullscreen::StdViewDockUndockFullscreen()
:Command("Std_ViewDockUndockFullscreen")
{
  sGroup       = QT_TR_NOOP("Standard-View");
  sMenuText    = QT_TR_NOOP("Document window");
  sToolTipText = QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
  sWhatsThis   = QT_TR_NOOP("Std_ViewDockUndockFullscreen");
  sStatusTip   = QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
  eType        = Alter3DView;
}

Action* StdViewDockUndockFullscreen::createAction()
{
    ActionGroup* pcAction = new ActionGroup(this,getMainWindow());
	pcAction->setDropDownMenu(true);
	pcAction->setText(QCoreApplication::translate(this->className(),sMenuText,0,QCoreApplication::CodecForTr));

	QAction* docked = pcAction->addAction(QObject::tr(QT_TR_NOOP("docked")));
	docked->setToolTip(QCoreApplication::translate(this->className(),sToolTipText,0,QCoreApplication::CodecForTr));
	docked->setWhatsThis(QCoreApplication::translate(this->className(),sWhatsThis,0,QCoreApplication::CodecForTr));
	docked->setStatusTip(QCoreApplication::translate(this->className(),sStatusTip,0,QCoreApplication::CodecForTr));
	docked->setShortcut(Qt::Key_D);
	docked->setCheckable(true);

	QAction* undock = pcAction->addAction(QObject::tr(QT_TR_NOOP("undock")));
	undock->setToolTip(QCoreApplication::translate(this->className(),sToolTipText,0,QCoreApplication::CodecForTr));
	undock->setWhatsThis(QCoreApplication::translate(this->className(),sWhatsThis,0,QCoreApplication::CodecForTr));
	undock->setStatusTip(QCoreApplication::translate(this->className(),sStatusTip,0,QCoreApplication::CodecForTr));
	undock->setShortcut(Qt::Key_U);
	undock->setCheckable(true);

	QAction* fullscr = pcAction->addAction(QObject::tr(QT_TR_NOOP("FullScreen")));
	fullscr->setToolTip(QCoreApplication::translate(this->className(),sToolTipText,0,QCoreApplication::CodecForTr));
	fullscr->setWhatsThis(QCoreApplication::translate(this->className(),sWhatsThis,0,QCoreApplication::CodecForTr));
	fullscr->setStatusTip(QCoreApplication::translate(this->className(),sStatusTip,0,QCoreApplication::CodecForTr));
	fullscr->setShortcut(Qt::Key_F11);
	fullscr->setCheckable(true);
	fullscr->setIcon(BitmapFactory().pixmap("view-fullscreen"));

	return pcAction;
}

void StdViewDockUndockFullscreen::activated(int Msg)
{
     ViewWindow* view = getMainWindow()->activeWindow();
 	if(!view)return;
 	if(Msg ==(int)view->currentViewMode())
 		return;
 
 	if(Msg == 0)
 	{
 		view->setCurrentViewMode(ViewWindow::Child);
 
 	}else if(Msg == 1)
 	{
 		view->setCurrentViewMode(ViewWindow::TopLevel);
 	}else if(Msg == 2)
 	{
 		view->setCurrentViewMode(ViewWindow::FullScreen);
 	}
}
bool StdViewDockUndockFullscreen::isActive()
{
 	ViewWindow* view = getMainWindow()->activeWindow();
 	if(qobject_cast<View3DInventor*>(view))
 	{
 		ActionGroup* pcAction = qobject_cast<ActionGroup*>(_pcAction);
 		if(pcAction)
 		{
 			int index = pcAction->checkedAction();
 			int mode = (int)(view->currentViewMode());
 			if(index != mode)
 			{
 				pcAction->setCheckedAction(mode);
 			}
 
 		}
		return true;
 	}
     return false;
}
void CreateViewCommands(void)
{
	CommandManager& CmdMgr = Application::Instance()->commandMananger();
	CmdMgr.addCommand(new StdCmdViewTop());
	CmdMgr.addCommand(new StdCmdViewBottom());
	CmdMgr.addCommand(new StdCmdViewLeft());
	CmdMgr.addCommand(new StdCmdViewRight());
	CmdMgr.addCommand(new StdCmdViewFront());
	CmdMgr.addCommand(new StdCmdViewRear());
	CmdMgr.addCommand(new StdViewDockUndockFullscreen());
}


